@extends "main_not_nav.html"

@block body

<form class="layui-form">
    {{ csrf_field }}

    <div class="layui-form-item">
        <label class="layui-form-label">网站名称</label>
        <div class="layui-input-inline">
            <input type="text" name="website" value="{{ data['website'] }}" lay-verify="required" autocomplete="off" placeholder="请输入内容" class="layui-input">
        </div>
        <div class="layui-form-mid layui-word-aux">[website] 网站名称及网站图标，将显示在浏览器的标签上。</div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">备案号</label>
        <div class="layui-input-inline">
            <input type="text" name="bei_an" value="{{ data['bei_an'] }}" lay-verify="required" autocomplete="off" placeholder="请输入内容" class="layui-input">
        </div>
        <div class="layui-form-mid layui-word-aux">
            [bei_an] 公网备案号，可以在 <a target="_blank" class="layui-font-blue" href="http://beian.miit.gov.cn">备案管理中心</a> 查询获取，将在登录页面下面显示。
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">版权信息</label>
        <div class="layui-input-inline">
            <input type="text" name="copyright" value="{{ data['copyright'] }}" lay-verify="required" autocomplete="off" placeholder="请输入内容" class="layui-input">
        </div>
        <div class="layui-form-mid layui-word-aux">[copyright] 版权信息，在后台登录页面显示版本信息并链接到备案到信息备案管理系统。</div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">屏幕水印</label>
        <div class="layui-input-inline">
            <select name="watermark_switch" id="watermark_switch" lay-verify="required">
                <option value="0">关</option>
                <option value="1">开</option>
            </select>
        </div>
        <div class="layui-form-mid layui-word-aux">[watermark_switch] 后台系统部分界面会出现屏幕水印。</div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="formDemo">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>

@endblock

@block js
<script>
    //Demo
    layui.use(['form', 'laydate'], function(){
        var form = layui.form;

        let watermark_switch_value = "{{ data['watermark_switch'] }}";
        $("#watermark_switch").find("option[value='"+watermark_switch_value+"']").attr('selected', true);

        form.render('select');

        //监听提交
        form.on('submit(formDemo)', function(data){
            //当前容器的全部表单字段，名值对形式：{name: value}
            // console.log(data.field);
            // layer.msg(JSON.stringify(data.field));
            $.ajax({
                url: "{{ uri }}/update",
                method: "put",
                data: data.field,
                dataType: "JSON",
                success: function (callback){
                    // console.log(callback);
                    layer.msg(callback.message);

                    if (callback.code === 1)
                    {
                        setTimeout(function(){
                            window.parent.location.reload();
                        }, 1500)
                    }
                }
            });

            return false;
        });
    });
</script>
@endblock